package com.my.stock.core;

import com.my.myTradeData.App;
import com.my.myTradeData.Trade;

public class TradeService implements TradeInterface {

	public static final int SIGNAL_BUY = 0;
	public static final int SIGNAL_SELL = 1;
	public static final int SIGNAL_LONGSTOP = 2;
	public static final int SIGNAL_SHORTSTOP = 3;

	public boolean sellPosition(String code, int number,double selllimit) {
		Trade trade = new Trade();
		trade.setCode(code);
		trade.setDirect(SIGNAL_SELL);
		trade.setNumber(number);
		trade.setSelllimit(selllimit);
		return App.tradeQueue.offer(trade);
	}

	public boolean buyPosition(String code, int number,double buylimit) {
		Trade trade = new Trade();
		trade.setCode(code);
		trade.setDirect(SIGNAL_BUY);
		trade.setNumber(number);
		trade.setBuylimit(buylimit);
		return App.tradeQueue.offer(trade);
	}

	public boolean longStop(String code, int number,double selllimit) {
		Trade trade = new Trade();
		trade.setCode(code);
		trade.setDirect(SIGNAL_LONGSTOP);
		trade.setNumber(number);
		trade.setSelllimit(selllimit);
		return App.tradeQueue.offer(trade);
	}

	public boolean shortStop(String code, int number,double buylimit) {
		Trade trade = new Trade();
		trade.setCode(code);
		trade.setDirect(SIGNAL_SHORTSTOP);
		trade.setNumber(number);
		trade.setBuylimit(buylimit);
		return App.tradeQueue.offer(trade);
	}

}
